var express = require('express');
var router = express.Router();
var GoodsController = require("../controller/goods_ctr")

router.use(function (req, res, next) {
    next()
});

router.post('/add', function (req, res, next) {
    let c = new GoodsController()
    c.Add(req.body, (err, result) => {
        res.json(result)
    })
});

router.post('/update', function (req, res, next) {
    let c = new GoodsController()
    c.Update(req.body, (err, result) => {
        res.json(result)
    })
});

router.post('/del', function (req, res, next) {
    let c = new GoodsController()
    c.Remove(req.body, (err, result) => {
        res.json(result)
    })
});

router.get('/list', function (req, res, next) {
    let c = new GoodsController()
    c.List(req.body, (err, result) => {
        res.json(result)
    })
});

router.get('/detail', function (req, res, next) {
    let c = new GoodsController()
    c.Detail(req.query, (err, result) => {
        res.json(result)
    })
});

module.exports = router;